package com.flower.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-19 19:45
 * 线程池的config管理
 */
@Configuration
public class ThreadPoolConfig {

    @Bean(name = "labelThreadPool")
    public ThreadPoolExecutor getThreadPoolExecutor() {

        return new ThreadPoolExecutor(20,100,5,
                TimeUnit.SECONDS,new LinkedBlockingDeque<>(40),
                new CustomNameThreadFactory("project"),
                new ThreadPoolExecutor.CallerRunsPolicy());

    }
}
